'use strict';

var paramutil = paramutil || {
	Set : function(dbgrid, param, title, type, mkid) {
		var height = 300;					   //文本、数值、单选数据类型默认参数修改框高度
		var item = param;
		if (item && (item.cszlx == "M"))       //如果参数值类型为列表型，则调整弹出窗高度
			height = 575;
		else if (item && (item.cszlx == "B"))   //如果参数值类型为布尔型，则调整弹出窗高度
			height = 296;
		mini.open({
			url : "public/cssz.html",
			title : title,
			width : "600",
			height : height,
			allowResize : false,
			onload : function() {
				var win = this.getIFrameEl().contentWindow;
				win.SetData(dbgrid,item,type,mkid);
			}
		});
	},
	QuerySet : function(dbgrid,csid,csmc,userid,roleid){
    	var loadfail = function (data){
			rs.showtips("错误", "查询错误,请稍候重试!", "warning");
    	};
    	var param = {
    		"csid": csid,
    		"csmc": csmc,
    		"userid" : userid,
    		"roleid" : roleid
    	};
    	dbgrid.load(param,null,loadfail);
    },
    Del : function(dbgrid,opttype,userid,roleid,mkid,cstype){
    	var success = function(data){
    		if (data.retcode == "0000"){
    			rs.showtips("成功", "参数删除成功!", "success");
    			dbgrid.reload();
    		}else{
    			rs.showtips("失败", data.retmsg, "warning");
    		}
    	};
    	var selectrow = dbgrid.getSelecteds();
    	if (selectrow.length > 0){
    		mini.confirm("是否确定删除当前选中的参数?","确定？",function(action){
    			if (action == "ok"){
    				var item = selectrow[0];
		    		var param = { 
	    				"csid": item.csid,
	    				"opttype": opttype,
	    				"type" : cstype,
	    				"userid" : userid,
	    				"roleid" : roleid,
	    				"mkid" : mkid
	    				};
		    		if (cstype=="F")
		    			rs.post("../sys/ParamProc.do",param,success);
		    		else
		    			rs.post("sys/ParamProc.do",param,success);
    			}
    		});
    	}else
    		rs.alert("请先选择需删除的参数,再执行此操作!");
    },
    ShowImportWin : function(dbgrid,cstype,opttype,title,userid,roleid,mkid){
    	rs.open({
    		url : "public/importParam.html?time="+new Date().getTime(),
			title : title,
			width : "700px",
			height : "500px",
			showModal : true,
			allowResize : true,
			onload : function() {
				var win = this.getIFrameEl().contentWindow;
				win.setData(dbgrid,cstype,opttype,userid,roleid,mkid);
			}
    	});
    }
};
